home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.db.net;
-
- import java.io.ByteArrayOutputStream;
- import java.io.DataInputStream;
- import java.io.DataOutputStream;
- import java.io.FilterOutputStream;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.OutputStream;
- import symjava.sql.SQLException;
-
- public abstract class Requester {
- String _reqDelim;
- MPlex _mplex;
- IO _io;
- ClientSession _sess;
-
- public Requester(ClientSession sess) {
- this._sess = sess;
- this._mplex = this._sess._mplex;
- this._reqDelim = new String(",");
- }
-
- public ClientSession getSession() {
- return this._sess;
- }
-
- protected IO getIO() throws NetException, SQLException {
- return this._mplex.getIO();
- }
-
- protected void releaseIO() {
- this._mplex.releaseIO(this._io);
- }
-
- protected void onObjectError(ServerObject obj) throws SQLException {
- if (obj.getType() == 49) {
- throw ((NetError)obj).toSQLException();
- } else if (obj.getType() == 68) {
- throw ((ExceptionList)obj).getSQLException();
- } else {
- throw new SQLException("SCALE object stream error.");
- }
- }
-
- public void execute() throws SQLException {
- ByteArrayOutputStream bytestream = new ByteArrayOutputStream(512);
- DataOutputStream outstream = new DataOutputStream(bytestream);
-
- try {
- try {
- this._io = this.getIO();
- } catch (NetException e) {
- throw new SQLException(((Throwable)e).getMessage());
- }
-
- InputStream e = this._io.getInputStream();
- synchronized(e){}
-
- try {
- outstream.writeByte(56);
- outstream.writeShort(0);
- this.writeRequest(outstream);
- EOT eot = new EOT();
- eot.write(outstream);
- byte[] b = bytestream.toByteArray();
- OutputStream out = this._io.getOutputStream();
- out.write(b);
- ((FilterOutputStream)outstream).close();
- SocketIS inStrm = (SocketIS)this._io.getInputStream();
- inStrm.reset();
- DataInputStream in = new DataInputStream(this._io.getInputStream());
- this.readResults(in);
- this.releaseIO();
- } catch (Throwable var15) {
- throw var15;
- }
-
- } catch (IOException var17) {
- this._mplex.connectionLost();
- throw new SQLServerConnException();
- } catch (ErrorException var18) {
- throw new SQLException("SCALE Server error");
- } catch (NetException e) {
- throw new SQLException("SCALE net error( " + ((Throwable)e).getMessage() + " )");
- }
- }
-
- protected abstract void readResults(DataInputStream var1) throws IOException, ErrorException, SQLException;
-
- protected abstract void writeRequest(DataOutputStream var1) throws IOException;
- }
-